﻿using Microsoft.Extensions.DependencyInjection;

using System.Reflection;

namespace LiteGafDemo.LiteAddins
{
    class IncludeServiceActivator
    {
        public string Name => MethodBase.GetCurrentMethod()!.DeclaringType!.Name.Replace("Activator", "");
        public int StartLevel => 5;

        public void Configure(IServiceCollection services)
        {
            services.AddSingleton<OrderService>();
        }

        /// <summary>
        /// Addin规约验证
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public bool Match(IServiceProvider provider, OrderService orderService)
        {
            return true;
        }

        /// <summary>
        /// 应用启动
        /// </summary>
        /// <param name="context"></param>
        public void Start(OrderService orderService)
        {
            orderService.PlaceOrder();
        }

        /// <summary>
        /// 应用停止
        /// </summary>
        /// <param name="context"></param>
        public void Stop()
        {
        }
    }

    class OrderService
    {
        public void PlaceOrder() { }
    }
}
